package com.chan.mediacamera.camera.filter;

import android.content.Context;
import android.opengl.GLES20;

import com.chan.mediacamera.util.OpenGlUtils;

public class SplitScreenFilter extends BaseFilter {
    private int vYcount;
    private int vXcount;

    private int xCount = 1;
    private int yCount = 1;

    public SplitScreenFilter(Context context) {
        super(context);
    }

    @Override
    public void onCreateShare() {
        mVertexShader = OpenGlUtils.loadShareFromAssetsFile("filter/default_vertex.glsl", mContext.getResources());
        mFragmentShader = OpenGlUtils.loadShareFromAssetsFile("filter/spiltscreen_fragment.glsl", mContext.getResources());
    }


    @Override
    public void onSurfaceCreated() {
        super.onSurfaceCreated();
        vYcount = GLES20.glGetUniformLocation(mProgram, "vYcount");
        vXcount = GLES20.glGetUniformLocation(mProgram, "vXcount");
    }

    @Override
    protected void onBindTexture() {
        GLES20.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
        GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT | GLES20.GL_DEPTH_BUFFER_BIT);

    }

    @Override
    protected void onSetExpandData() {
        super.onSetExpandData();
        GLES20.glUniform1i(vXcount, xCount);
        GLES20.glUniform1i(vYcount, yCount);
    }

    @Override
    protected void onSizeChanged(int width, int height) {

    }

    public void setxCount(int xCount) {
        this.xCount = xCount;
    }

    public void setyCount(int yCount) {
        this.yCount = yCount;
    }
}
